#: import environ os.environ
#: import gch kivy.utils.get_color_from_hex

#: import StiffScrollEffect kivymd.effects.stiffscroll.StiffScrollEffect

#: import NavigationItem libs.baseclass.tabnavigation.NavigationItem
#: import NavigationBar libs.baseclass.tabnavigation.NavigationBar

#: import RallyOverviewScreen libs.baseclass.overview_screen.RallyOverviewScreen
#: import RallyAccountsScreen libs.baseclass.accounts_screen.RallyAccountsScreen
#: import RallyBillsScreen libs.baseclass.bills_screen.RallyBillsScreen
#: import RallyBudgetsScreen libs.baseclass.budgets_screen.RallyBudgetsScreen
#: import RallySettingsScreen libs.baseclass.settings_screen.RallySettingsScreen


<RallyRootScreen>
    md_bg_color: gch("#33333d")

    MDBoxLayout:
        orientation: 'vertical'

        NavigationBar:
            id: nav_bar

            NavigationItem:
                text: "OVERVIEW"
                icon: "chart-pie"
                on_release:
                    scr_manager.transition.direction = "right"
                    scr_manager.current = "OVERVIEW"

            NavigationItem:
                text: "ACCOUNTS"
                icon: "currency-usd"
                on_release:
                    scr_manager.transition.direction = "right" \
                    if scr_manager.current in ["BILLS", "BUDGETS", "SETTINGS"] \
                    else "left"
                    scr_manager.current = "ACCOUNTS"

            NavigationItem:
                text: "BILLS"
                icon: "currency-usd-off"
                on_release:
                    scr_manager.transition.direction = "right" \
                    if scr_manager.current in ["BUDGETS", "SETTINGS"] \
                    else "left"
                    scr_manager.current = "BILLS"

            NavigationItem:
                text: "BUDGETS"
                icon: "shopping"
                on_release:
                    scr_manager.transition.direction = "left" \
                    if scr_manager.current in ["OVERVIEW", "ACCOUNTS", "BILLS"] \
                    else "right"
                    scr_manager.current = "BUDGETS"

            NavigationItem:
                text: "SETTINGS"
                icon: "cog"
                on_release:
                    scr_manager.transition.direction = "left"
                    scr_manager.current = "SETTINGS"

        ScreenManager:
            id: scr_manager

            RallyOverviewScreen:
                name: "OVERVIEW"

            RallyAccountsScreen:
                name: "ACCOUNTS"

            RallyBillsScreen:
                name: "BILLS"

            RallyBudgetsScreen:
                name: "BUDGETS"

            RallySettingsScreen:
                name: "SETTINGS"


<ScrollView>
    bar_width: 0
    effect_cls: StiffScrollEffect


<RallyLabel@MDLabel>
    adaptive_height: True


<RallyListItem>
    size_hint_y: None
    height: dp(60)

    canvas:
        Color:
            rgba:
                self.theme_cls.divider_color
        Line:
            points: (root.x+dp(16), root.y, root.x+self.width-dp(16)-0, root.y)
    canvas.before:
        Color:
            rgba: gch("#31313b")
        Rectangle:
            size: self.size
            pos: self.pos

    MDBoxLayout:
        adaptive_size: True
        padding: dp(15)
        pos_hint: {"center_x": .5, "center_y": .5}

        MDIcon:
            icon: "minus-thick"
            halign: "center"
            pos_hint: {"center_y": .5}
            theme_text_color: "Custom"
            text_color: root.bar_color

            canvas.before:
                PushMatrix
                Rotate:
                    angle: 90
                    origin: self.center
            canvas.after:
                PopMatrix

    MDBoxLayout:
        orientation: 'vertical'
        adaptive_height: True
        pos_hint: {"center_x": .5, "center_y": .5}
        spacing: dp(2)

        RallyLabel:
            text: root.text
            font_style: "Subtitle1"

        RallyLabel:
            text: root.secondary_text
            theme_text_color: "Hint"
            font_style: "Button"

    MDBoxLayout:
        orientation: 'vertical'
        padding: (0, 0, 0, dp(10))
        adaptive_height: True

        RallyLabel:
            text: root.tertiary_text
            theme_text_color: "Secondary"
            pos_hint: {"center_x": .5, "center_y": .5}
            halign: "right"
            font_style: "H3"
            font_size: sp(20)

    MDBoxLayout:
        adaptive_size: True
        padding: dp(15)
        pos_hint: {"center_x": .5, "center_y": .5}

        MDIcon:
            icon: "chevron-right"
            halign: "center"
            pos_hint: {"center_y": .5}
            theme_text_color: "Hint"
